﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MySql.Data.MySqlClient;
namespace 易览漫画
{

    public partial class AllBooks : System.Web.UI.Page
    {



       public static MySqlDataAdapter adapter;

        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                this.getlist();
            }


        }
        public static DataSet SET()
        {
            MySqlConnection conn = new MySqlConnection("Data Source=127.0.0.1;Initial Catalog=test;User ID=root;Password=123456");
            string sql = "select * from yilanmanhua";
            adapter = new MySqlDataAdapter(sql, conn);
            DataSet set = new DataSet();
            adapter.Fill(set, "list");
            
            return set;
        }


        private void getlist()
        {

            DataSet set= SET();
            this.list.DataSource = set.Tables["list"];
            this.list.DataBind();
            this.list.HeaderRow.Cells[2].Text = "图书ID号";
            this.list.HeaderRow.Cells[3].Text = "分类";
            this.list.HeaderRow.Cells[4].Text = "作者";
            this.list.HeaderRow.Cells[5].Text = "名称";
            this.list.HeaderRow.Cells[6].Text = "日期";
            this.list.HeaderRow.Cells[7].Text = "价格";
            this.list.HeaderRow.Cells[8].Text = "简介";
           // this.list.HeaderRow.Cells[9].Text = "日期";

        }

        protected void linkbtnclick(object sender, CommandEventArgs e)
        {
            string id = e.CommandArgument.ToString();
            
            int m = Convert.ToInt32(id);
            DataSet set = SET();
                      
            set.Tables["list"].Rows[m-1].Delete();
            MySqlCommandBuilder bul=new MySqlCommandBuilder(adapter);
            
            adapter.Update(set,"list");
            this.list.DataSource = set.Tables["list"];
                       
            this.list.DataBind();
            
        }
    }
}